<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<ui:composition template="/template.xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:f="http://java.sun.com/jsf/core">
    <ui:define name="title">
        <h:outputText value="Pesquisa de notas"></h:outputText>
    </ui:define>
    <ui:define name="body">
        <h:panelGroup layout="block" id="painel">

            <p:messages />
            <h:form prependId="false">
                <h:panelGrid columns="2" >
                    <h:outputText value="Codigo da venda:" />
                    <h:inputText value="#{RelatorioController.idvenda}"
                                 />
                    <h:outputText value="CPF:" />
                    <h:inputText value="#{RelatorioController.venda.cliente.cpf}" maxlength="13"/>
                    <h:outputText value="Data da venda:" />

                    <p:calendar pattern="dd/MM/yyyy" readOnlyInputText="true"
                                value="#{RelatorioController.venda.data}"
                                />
                    <!--<h:inputText value="#{RelatorioController.venda.data}" maxlength="10" >
                        <f:convertDateTime pattern="dd/MM/yyyy" />
                    </h:inputText>-->

                    <p:commandButton value="Pesquisar" action="#{RelatorioController.pesquisarNotas}"
                                     update="tabelal" type="submit" ajax="false"/>

                </h:panelGrid>
                <p:dataTable value="#{RelatorioController.listaVenda}" var="vendas" widgetVar="tabela"
                             emptyMessage="Nada encontrado" firstPageLinkLabel="Primeiro"
                             lastPageLinkLabel="Último" nextPageLinkLabel="Próximo"
                             previousPageLinkLabel="Anterior"
                             rows="10" >
                    <p:column >
                        <f:facet name="header">Codigo </f:facet>
                        <h:outputText value="#{vendas.idVenda}" />
                    </p:column>
                    <p:column >
                        <f:facet name="header">Data </f:facet>
                        <h:outputText value="#{vendas.data}" >
                            <f:convertDateTime pattern="dd/MM/yyyy" />
                        </h:outputText>
                    </p:column>
                    <p:column >
                        <f:facet name="header">CPF</f:facet>
                        <h:outputText value="#{vendas.cliente.cpf}" />
                    </p:column>
                    <p:column>
                        <h:commandButton value="Visualizar nota" action="#{RelatorioController.mostrarNotaFiscal}" >
                            <f:setPropertyActionListener value="#{vendas}" target="#{RelatorioController.venda}" />
                        </h:commandButton>
                    </p:column>
                </p:dataTable>
            </h:form>

            <h:form>
                
                <h:commandButton value="Cancelar" action="#{RelatorioController.cancelar}" />
            </h:form>
        </h:panelGroup>
    </ui:define>
</ui:composition>
